package ecom.beans;

import java.util.regex.Pattern;

import javax.ejb.Stateless;

public class ValidateRegEx {

	// Valide Prenom
	public static boolean validePrenom(String prenom) {
		return prenom.matches("[a-zA-Z]*");
	}

	// validate Nom
	public static boolean valideNom(String nom) {
		return nom.matches("[a-zA-z]+([ '-][a-zA-Z]+)*");
	}

	// Valide Adresse
	public static boolean valideAddress(String address) {
		return address.matches("\\d+\\s+([a-zA-Z]+|[a-zA-Z]+\\s[a-zA-Z]+)");
	}

	// Valide Pays
	public static boolean validePays(String pays) {
		return pays.matches("([a-zA-Z]+|[a-zA-Z]+\\s[a-zA-Z]+)");
	}

	// Valide Numero de telephone
	public static boolean valideTel(String tel) {
		return tel.matches("[0-9]\\d{1} [0-9]\\d{1} [0-9]\\d{1} [0-9]\\d{1} [0-9]\\d{1}");
	}
	
	// Valide code postal
	  public static boolean valideCode( String code )
	  {
	  return code.matches( "\\d{5}" );
	  }

	public static boolean valideEmail(String email) {

		email = email.toUpperCase();
		return Pattern.matches("^[A-Z0-9._%+-]+@[A-Z0-9.-]+\\.[A-Z]{2,4}$",
				email);

	}

}
